Skip to content

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented May 14, 2025

Proposed changes (including videos or screenshots)

Sometimes you could get stuck on startup due to a dependency on the settings service not being met:

@rocket.chat/meteor:dsv: W20250514-15:44:01.543(-3)? (STDERR) === UnHandledPromiseRejection ===
@rocket.chat/meteor:dsv: W20250514-15:44:01.543(-3)? (STDERR) Error: Timeout while waiting for LocalBroker services: settings
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR)     at Timeout.<anonymous> (/Users/diegosampaio/dev/Rocket.Chat/packages/core-services/src/LocalBroker.ts:215:20)
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR)     at listOnTimeout (node:internal/timers:594:17)
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR)     at processTimers (node:internal/timers:529:7)
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR) ---------------------------------
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR) Errors like this can cause oplog processing errors.
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR) Setting EXIT_UNHANDLEDPROMISEREJECTION will cause the process to exit allowing your service to automatically restart the process
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR) Future node.js versions will automatically exit the process
@rocket.chat/meteor:dsv: W20250514-15:44:01.544(-3)? (STDERR) =================================
@rocket.chat/meteor:dsv: I20250514-15:44:01.754(-3)? [2025-05-14T18:44:01.533Z] ERROR (LocalBroker/26705 on Diegos-MacBook-Pro.local): Timeout while waiting for LocalBroker services: settings
@rocket.chat/meteor:dsv: I20250514-15:44:01.755(-3)?     err: {
@rocket.chat/meteor:dsv: I20250514-15:44:01.755(-3)?       "type": "Error",
@rocket.chat/meteor:dsv: I20250514-15:44:01.755(-3)?       "message": "Timeout while waiting for LocalBroker services: settings",
@rocket.chat/meteor:dsv: I20250514-15:44:01.756(-3)?       "stack":
@rocket.chat/meteor:dsv: I20250514-15:44:01.756(-3)?           Error: Timeout while waiting for LocalBroker services: settings
@rocket.chat/meteor:dsv: I20250514-15:44:01.756(-3)?               at Timeout.<anonymous> (/Users/diegosampaio/dev/Rocket.Chat/packages/core-services/src/LocalBroker.ts:215:20)
@rocket.chat/meteor:dsv: I20250514-15:44:01.756(-3)?               at listOnTimeout (node:internal/timers:594:17)
@rocket.chat/meteor:dsv: I20250514-15:44:01.757(-3)?               at processTimers (node:internal/timers:529:7)
@rocket.chat/meteor:dsv: I20250514-15:44:01.757(-3)?     }
@rocket.chat/meteor:dsv: => Exited with code: 1
@rocket.chat/meteor:dsv: => Your application is crashing. Waiting for file change.

I was able to reproduce this issue while using a remote MongoDB server, so things were much slower and apparently ran in a different order than usual causing it to get stuck.

Issue(s)

ARCH-1725

Steps to test or reproduce

Further comments


Pull Request Description

This pull request addresses a race condition issue in the LocalBroker service within the Rocket.Chat repository. The changes focus on enhancing the service registration logic by implementing a filter. This filter ensures that only services which are not already started or not present in the services map are registered. This improvement aims to prevent potential conflicts and ensure smoother operation of the LocalBroker service's dependencies. The changes are made in the packages/core-services/src/LocalBroker.ts file.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented May 14, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented May 14, 2025

⚠️ No Changeset found

Latest commit: 0987b80

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kody-ai
Copy link

kody-ai bot commented May 14, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@github-actions
Copy link
Contributor

github-actions bot commented May 14, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35997/

Built to branch gh-pages at 2025-07-30 12:28 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented May 14, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.84%. Comparing base (f040b27) to head (0987b80).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35997      +/-   ##
===========================================
+ Coverage    65.83%   65.84%   +0.01%     
===========================================
  Files         3186     3186              
  Lines       106646   106645       -1     
  Branches     20315    20316       +1     
===========================================
+ Hits         70207    70223      +16     
+ Misses       33768    33755      -13     
+ Partials      2671     2667       -4     
Flag Coverage Δ
e2e 58.07% <ø> (-0.02%) ⬇️
unit 71.11% <0.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sampaiodiego sampaiodiego force-pushed the chore-fix-race-condition-localbroker branch from 5e0058c to dd25cff Compare July 24, 2025 20:38
@sampaiodiego sampaiodiego marked this pull request as ready for review July 24, 2025 20:38
@sampaiodiego sampaiodiego force-pushed the chore-fix-race-condition-localbroker branch from dd25cff to 0987b80 Compare July 30, 2025 12:23
@ggazzo ggazzo added this to the 7.10.0 milestone Jul 30, 2025
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Jul 30, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 30, 2025
@ggazzo ggazzo merged commit 0776b21 into develop Jul 30, 2025
52 checks passed
@ggazzo ggazzo deleted the chore-fix-race-condition-localbroker branch July 30, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants